import {
  Controller,
  Get,
  Post,
  Body,
  Patch,
  Param,
  Delete,
  HttpCode,
} from '@nestjs/common';
import { DirectoryService } from './directory.service';
import { CreateDirectoryDto } from './dto/create-directory.dto';
import { UpdateDirectoryDto } from './dto/update-directory.dto';
import { Auth } from '@/jwt/jwt.decorator';

@Controller('directory')
export class DirectoryController {
  constructor(private readonly directoryService: DirectoryService) {}

  //添加目录
  @Post()
  @HttpCode(200)
  @Auth()
  create(@Body() dto: CreateDirectoryDto) {
    return this.directoryService.create(dto);
  }
  //查看所有目录
  @Get()
  @Auth()
  findAll() {
    return this.directoryService.findAll();
  }
  //查找具体目录
  @Get(':id')
  @Auth()
  findOne(@Param('id') id: string) {
    return this.directoryService.findOne(+id);
  }
  //修改目录
  @Patch(':id')
  @Auth()
  update(
    @Param('id') id: string,
    @Body() updateDirectoryDto: UpdateDirectoryDto,
  ) {
    return this.directoryService.update(+id, updateDirectoryDto);
  }
  //删除目录
  @Delete(':id')
  @Auth()
  remove(@Param('id') id: string) {
    return this.directoryService.remove(+id);
  }
}
